import sass from 'sass'

export default {
    AppURL: "",
    mode: 'universal',
    head: {
        script: [
            {src: 'https://cdn.tailwindcss.com'}
        ],
        title: 'Manong Cloud',
        meta: [
            {charset: 'utf-8'},
            {name: 'viewport', content: 'width=device-width, initial-scale=1'}
        ],
        link: [{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}]
    },
    css: ['~/assets/css/main.css', 'element-ui/lib/theme-chalk/index.css'],// 引入 ElementUI 样式],
    plugins: [
        {src: '~/plugins/element-ui', ssr: false}, // 仅在客户端加载
        {src: '~/plugins/cloud', mode: 'client'},
        { src: '~/plugins/tailwind-config.js', mode: 'client' }
    ],
    axios: {
        baseURL: '/api'
    },
    build: {
        postcss: false, // 完全禁用 PostCSS（可能影响其他依赖）
        transpile: [/^element-ui/], // 确保 ElementUI 在服务端渲染时正确编译
        publicPath: '/_nuxt/',
        // 开发环境不需要预渲染
        prerender: {
            crawl: false
        },
        extend(config, {isDev, isClient}) {
            if (isDev) {
                config.devtool = 'source-map';
            }
            // 为 Chart.js 添加 Babel 加载器
            config.module.rules.push({
                test: /chart\.js/,
                loader: 'babel-loader',
                options: {
                    presets: ['@nuxtjs/babel-preset-app']
                }
            })
        },
        loaders: {
            scss: {
                implementation: sass,
                sassOptions: {
                    // 关键：屏蔽旧版 API 警告
                    silenceDeprecations: ['legacy-js-api'],
                },
            },
        }
    },
    server: {
        port: false,
        host: false
    }
};
